package com.rz.quartz.job;

import org.quartz.*;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @program: quartz
 * @description: 我的定时任务
 * @author: rZ
 * @create: 2020-02-05 10:47
 **/
//@DisallowConcurrentExecution //不允许并发执行，等待上一次执行完毕，才新开线程执行下一次
@Component
public class MyJob implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        /*//创建工作详情
        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        //获取工作的名称
        String name = jobDetail.getKey().getName();//任务名
        String group = jobDetail.getKey().getGroup();//任务group
        String job = jobDetail.getJobDataMap().getString("data");//任务中的数据
        System.out.println("job执行，job名："+name+" group:"+group+" data:"+job+new Date());*/

        System.out.println("执行定时任务"+new Date());
    }

    public void sayHello(){
        System.out.println("hello world!!!"+new Date());
    }
}
